<template>
    <div class="form-checkbox" :active="active ? 'checked' : '' " @click="doChange()">
        <em><svg-icon name="checkbox-active" /></em>
        <span v-if="$slots.default">
            <slot></slot>
        </span>
    </div>
</template>
<script>
export default {
    props: {
        value: { type: [String, Number, Boolean], default: false },
    },
    data () {
        return {
        };
    },
    computed: {
        active () {
            return !!this.value
        }
    },

    methods: {
        doChange () {
            if (!this.active) {
                this.$emit('input', true)
            } else {
                this.$emit('input', false)
            }
        },
    },
    created () {
    },

    mounted () {
    },
    beforeDestroy () {
    }
};
</script>
<style lang="scss" scoped>
.form-checkbox {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    em {
        box-sizing: border-box;
        width: 16px;
        height: 16px;
        background: #ffffff;
        border-radius: 2px;
        border: 1px solid #9e9e9e;
        position: relative;

        svg {
            position: absolute;
            width: 10px;
            height: 10px;
            left: 50%;
            top: 50%;
            margin-left: -5px;
            margin-top: -5px;
            color: #ea4c89;
            display: none;
        }
    }

    span {
        font-size: 14px;
        font-family: Roboto-Regular, Roboto;
        font-weight: 400;
        color: #000000;
        line-height: 16px;
        margin-left: 4px;
    }

    &[active='checked'] {
        em svg {
            display: block;
        }
    }
}
</style>
